package com.example.ui;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class CustomLayoutActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_layout_title);

        //隐藏自带标题栏
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }

        //设置标题栏点击事件
        findViewById(R.id.back).setOnClickListener(this::todo1);
        findViewById(R.id.edit).setOnClickListener(this::todo2);
    }

    private void todo2(View view) {
        Toast.makeText(getBaseContext(), "You click Edit button", Toast.LENGTH_SHORT).show();
    }

    private void todo1(View view) {
        ((Activity) getBaseContext()).finish();
    }
}